package com.liuguang.common.utils;

import org.springframework.core.io.ClassPathResource;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

/**
 * @ClassName: ResourceUtil
 * @Description：
 * @Author: wanghr
 * Date: 2:01 PM 2020/9/15
 * Version: 1.0
 */
public class ResourceUtil {
    public static String getKeyInfo(String url) throws IOException {
        ClassPathResource resource = new ClassPathResource(url);
        File resourceFile = resource.getFile();
        BufferedReader bufferedReader = new BufferedReader(new FileReader(resourceFile));
        StringBuffer stringBuffer = new StringBuffer();
        String s;
        //防止公钥文件如果保存形式是：多行
        while ((s = bufferedReader.readLine()) != null) {
            stringBuffer.append(s);
        }
        return stringBuffer.toString();
    }
}
